<script>
export default {
  name: 'DzDialog',
  props: {
    value: Boolean,
    title: {
      type: String,
      default: '',
    },
    titleImg: {
      type: String,
      default: '',
    },
  },
  methods: {
    handleClose() {
      this.$emit('input', false);
    },
  },
};
</script>

<template>
  <div v-if="value" class="dzq-dialog">
    <div class="dzq-dialog-inner">
      <div class="dzq-dialog-header">
        <div class="dzq-dialog-header_right">
          <img v-if="titleImg" class="dzq-dialog-title_img" :src="titleImg" alt="img" />
          <div class="dzq-dialog-title">{{ title }}</div>
        </div>
        <div class="dzq-dialog-header_left" @click="handleClose">
          <i class="icon-close"></i>
        </div>
      </div>
      <div class="dzq-dialog-content">
        <slot />
      </div>
      <div class="dzq-dialog-footer">
        <div class="dzq-dialog-btn-close dzq-btn-default" @click="handleClose">关闭</div>
      </div>
    </div>
  </div>
</template>

<style lang="scss">
.dzq-dialog {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: rgba($color: #000000, $alpha: 0.6);
  z-index: 1000;

  &-inner {
    padding: 28px;
    width: 470px;
    background-color: #fff;
  }

  &-header {
    margin-bottom: 27px;
    display: flex;
    align-items: center;
    justify-content: space-between;
  }

  &-header_right {
    display: flex;
    align-items: center;
    .dzq-dialog-title_img {
      margin-right: 17px;
      width: 57px;
      height: 57px;
      border-radius: 100%;
    }
    .dzq-dialog-title {
      font-size: 18px;
      letter-spacing: 0px;
      color: #242d4e;
      font-weight: bold;
    }
  }

  &-content {
    padding-right: 10px;
    max-height: 400px;
    margin-bottom: 17px;
    font-size: 14px;
    color: #91a2bb;
    line-height: 30px;
    text-align: justify;
    overflow-y: auto;

    @include scrollbar();
  }

  &-header_left {
    width: 50px;
    height: 50px;
    display: flex;
    align-items: center;
    justify-content: flex-end;
  }

  .icon-close {
    display: inline-block;
    width: 14px;
    height: 14px;
    background-image: url(https://imgcache.qq.com/open_proj/proj_qcloud_v2/event/2020/pc/discuz/css/img/bg/dialog-icon-hd-close.png);
    background-repeat: no-repeat;
    background-size: 100%;
    cursor: pointer;
  }

  &-footer {
    text-align: right;
  }
}

@media screen and (max-width: 768px) {
  .dzq-dialog {
    &-inner {
      width: 90%;
    }
  }
}
</style>
